<%--
  Created by IntelliJ IDEA.
  User: kinsky
  Date: 2022/3/15
  Time: 21:23
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <%--引入CSS样式--%>
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/image/smallLogo.svg" type="image/x-icon">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/layui/css/layui.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/car-search.css">
    <%--引入jquery--%>
    <script src="${pageContext.request.contextPath}/js/jquery-3.6.0.min.js"></script>
    <%--    TODO 引入百度地图API--%>
    <meta http-equiv="Content-Type" content="text/html" ; charset=utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <%--引入百度地图API--%>
    <style>

        <%--        悬浮在a标签上会出现的效果--%>
        .cus_title .logo .title_list li a:hover + span {
            background-image: url("${pageContext.request.contextPath}/image/list_buttom.png");
            background-size: 12px 6px;
        }

        /*给a标签上色*/
        .cus_title .logo .title_list li .own_car {
            color: #23b7b7 !important;
        }

        /*给span标签加三角形*/
        .cus_title .logo .title_list li .by_car {
            background-image: url("${pageContext.request.contextPath}/image/list_buttom.png");
            background-size: 12px 6px;
        }
    </style>

    <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=XWqaiRYZhVP50MOC701ii9PHsULw8XnV"></script>
</head>
<body>
<%--1.页头--%>
<jsp:include page="../common/head.jsp"/>

<%--2.内容--%>
<div class="content" id="clear_float">
    <%--多条件动态查询--%>
    <div class="choosecartype">
        <%--form表单开始--%>
        <form action="">
            <div class="term clearfix">
                <ul class="first">
                    <li>
                        <label class="key">
                            取车门店：
                        </label>
                        <div class="citystore">
                            <input class="citysel input-txt getCite" id="J-city-get" name="PickUpCity" type="text"
                                   value="苏州">
                            <input class="mendian input-txt fl" id="borrow-store" name="storeBorrow" type="text"
                                   value="寒山寺店" list="borrow-store-list">
                            <datalist id="borrow-store-list"></datalist>
                            <span id="borrow-store-id" style="display: none;"></span>
                        </div>
                        <label class="ckb-scsm ">
                            <input class="checkboxin" name="IsSendService" type="checkbox">
                            <span>送车上门</span>
                        </label>
                    </li>
                    <li>
                        <label class="key">
                            还车门店：
                        </label>
                        <div class="citystore">
                            <input class="citysel input-txt returnCity" id="J-city-put" name="PickUpCity" type="text"
                                   value="苏州">
                            <input class="mendian input-txt" id="return-store" name="storeReturn" type="text"
                                   value="寒山寺店" list="return-store-list">
                            <datalist id="return-store-list"></datalist>
                            <span id="return-store-id" style="display: none;"></span>
                        </div>
                        <label class="ckb-scsm ">
                            <input class="checkboxin" name="IsSendService" type="checkbox">
                            <span>上门取车</span>
                        </label>
                    </li>

                </ul>
                <ul class="second">
                    <li>
                        <label class="key">
                            取车时间：
                        </label>
                        <div class="get-time">
                            <input class="car-date input-txt" id="test-limit-one" name="getCarDate" type="text">
                            <input class="car-time input-txt" id="test-limit-three" name="getCarTime" type="text">
                        </div>
                    </li>
                    <li>
                        <label class="key">
                            还车时间：
                        </label>
                        <div class="get-time">
                            <input class="car-date input-txt" id="test-limit-two" name="getCarDate" type="text">
                            <input class="car-time input-txt" id="test-limit-four" name="getCarTime" type="text">
                        </div>
                    </li>
                </ul>
                <input class="submit-btn" type="button" value="查 询">
            </div>
        </form>
        <%--form表单结束--%>
        <!--多条件选择区域-->
        <div class="prompt-box clearfix">
            <div class="lease-prompt">
                <%--                *当前选定租期：--%>
                <%--                <span>2</span>--%>
                <%--                天--%>
            </div>
        </div>
        <div class="car-box-body">
            <div class="choose-typebox" id="choose-typebox">
                <div class="choose-model" id="choose-model">
                    <a href="javascript:void(0)" class="active">
                        <div style="display: none;"><p>全部</p></div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>经济型</p>
                            <span class="model-pic2"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>舒适型</p>
                            <span class="model-pic3"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>精英型</p>
                            <span class="model-pic4"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>SUV</p>
                            <span class="model-pic5"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>5-15座商务</p>
                            <span class="model-pic6"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>电动型</p>
                            <span class="model-pic7"></span>
                        </div>
                    </a>
                    <a href="javascript:void(0)">
                        <div class="model-classify">
                            <p>高端车</p>
                            <span class="model-pic8"></span>
                        </div>
                    </a>
                </div>
                <div class="chose-branch">
                    <div class="choose-brand choose-ck">
                        <span>品牌：</span>
                        <div class="brandlist" id="brandlist">
                            <a class="active" href="javascript:void(0)">全部</a>
                            <a href="javascript:void(0)">雪佛兰</a>
                            <a href="javascript:void(0)">大众</a>
                            <a href="javascript:void(0)">福特</a>
                            <a href="javascript:void(0)">本田</a>
                            <a href="javascript:void(0)">丰田</a>
                            <a href="javascript:void(0)">马自达</a>
                            <a href="javascript:void(0)">吉利</a>
                            <a href="javascript:void(0)">标致</a>
                            <a href="javascript:void(0)">别克</a>
                            <a href="javascript:void(0)">铃木</a>
                            <a href="javascript:void(0)">华晨华颂</a>
                            <a href="javascript:void(0)">雪铁龙</a>
                            <a href="javascript:void(0)">现代</a>
                            <a href="javascript:void(0)">宝马</a>
                            <a href="javascript:void(0)">奇瑞</a>
                            <a href="javascript:void(0)">比亚迪</a>
                            <a href="javascript:void(0)">奥迪</a>
                            <a href="javascript:void(0)">奔驰</a>
                            <a href="javascript:void(0)">长安</a>
                            <a href="javascript:void(0)">东南</a>
                            <a href="javascript:void(0)">福田</a>
                            <a href="javascript:void(0)">汇众</a>
                            <a href="javascript:void(0)">江淮</a>
                            <a href="javascript:void(0)">江铃</a>
                            <a href="javascript:void(0)">金杯</a>
                            <a href="javascript:void(0)">金龙</a>
                            <!--过第二行后的-->
                            <a href="javascript:void(0)">五菱</a>
                            <a href="javascript:void(0)">东风日产</a>

                        </div>
                    </div>
                    <div class="choose-price choose-ck">
                        <span>价格:</span>
                        <div class="pricelist" id="pricelist">
                            <a class="active" href="javascript:void(0)">全部</a>
                            <a href="javascript:void(0)">100元以下</a>
                            <a href="javascript:void(0)">100-200元</a>
                            <a href="javascript:void(0)">200-300元</a>
                            <a href="javascript:void(0)">300元以上</a>
                        </div>
                    </div>
                    <div class="choose-gear choose-ck">
                        <span>排挡:</span>
                        <div class="grarlist" id="grarlist">
                            <a class="active" href="javascript:void(0)">全部</a>
                            <a href="javascript:void(0)">手动</a>
                            <a href="javascript:void(0)">自动</a>
                            <a href="javascript:void(0)">无级变速</a>
                            <a href="javascript:void(0)">手自一体</a>
                            <a href="javascript:void(0)">双离合</a>
                        </div>
                    </div>
                    <div class="choose-seat choose-ck">
                        <span>座位</span>
                        <div class="seatlist" id="seatlist">
                            <a class="active" href="javascript:void(0)">全部</a>
                            <a href="javascript:void(0)">2座</a>
                            <a href="javascript:void(0)">4座</a>
                            <a href="javascript:void(0)">5座</a>
                            <a href="javascript:void(0)">7座</a>
                        </div>
                    </div>
                </div>
            </div>
            <div class="sort" id="sort">
                <ul class="field-orderby" id="field-orderby">
                    <li>
                        <a href="javascript:void(0)" class="field-orderby-active">默认排序</a>
                    </li>
                    <li>
                        <a class="order-by-price" href="javascript:void(0)">按租金降序</a>
                    </li>
                    <li>
                        <a class="order-by-price" href="javascript:void(0)">按租金升序</a>
                    </li>

                    <li>
                        <a href="javascript:void(0)">按排量降序</a>
                    </li>
                    <li>
                        <a href="javascript:void(0)">按排量升序</a>
                    </li>
                </ul>
                <div class="bottom-right">
                    *共有<c:if test="${!empty pageInfo}"><span>${pageInfo.total}</span></c:if>
                    <c:if test="${empty pageInfo}"><span>0</span></c:if>
                    种车型可以租用
                </div>
            </div>
        </div>
    </div>
    <!--======内容右边===========-->
    <div class="step1-body-right">
        <!--百度地图容器-->
        <div style="width:270px;height:270px;border:#ccc solid 1px;" id="container"></div>
        <ul id="right-store">
            <li>取车门店：</li>
            <li>
                <h4>寒山寺店</h4>
            </li>
            <li>
                <span>江苏省苏州市姑苏区和园路197号102室</span>
            </li>
            <li>
                <strong>门店电话：<span>15736978888</span></strong>
            </li>
            <li>
                <strong>营业时间：<span>8:00-18:00</span></strong>
            </li>
        </ul>
    </div>
    <%--车辆列表显示--%>
    <div class="det-carlist">

        <c:if test="${!empty dataInfo}">
            ${dataInfo}
        </c:if>

        <ul>

            <%--搜索框出来的分页信息--%>
            <c:if test="${!empty pageInfo}">
                <c:forEach items="${pageInfo.list}" var="car">

                    <li class="licar-picbox">
                        <div class="licar-picinfo">
                            <img src="${pageContext.request.contextPath}${car.carImage}">
                            <input type="hidden" value="${car.carId}">
                        </div>
                        <div class="licar-namebox">
                            <p class="car-nameinfo"><span>${car.carBrand} ${car.carName}</span></p>
                            <p class="car-introinfo">
                                <span>自动</span>
                                <span>|</span>
                                <span>${car.carEngineCapcity}</span>
                                <span>T</span>
                                <a href="${pageContext.request.contextPath}/car/${car.carId}?menberId=${customer.memberId}"
                                   class="show-car-detail">车辆详情</a>
                            </p>
                        </div>
                        <div class="licar-info">
                            <p class="condition1">
                                    <span class="carprice">
                                        <i class="symbol">￥</i>
                                        <em class="total-price">${car.carDailyPrice}</em>/日均
                                    </span>
                                <span class="licar-btn">
                                        <c:if test="${!empty customer}">
                                            <a class="create_order" href="javascript:void(0)">预订</a>
                                        </c:if>
                                        <c:if test="${empty customer}">
                                            <a href="${pageContext.request.contextPath}/customer/login.jsp">预订</a>
                                        </c:if>
                                    </span>
                            </p>
                        </div>
                    </li>
                </c:forEach>
            </c:if>

            <%--查询所有车辆--%>
            <c:if test="${!empty pageInfoAll}">
                <c:forEach items="${pageInfoAll.list}" var="car">

                    <li class="licar-picbox">
                        <div class="licar-picinfo">
                            <img src="${pageContext.request.contextPath}${car.carImage}">
                            <input type="hidden" value="${car.carId}">
                        </div>
                        <div class="licar-namebox">

                            <p class="car-nameinfo"><span>${car.carBrand} ${car.carName}</span></p>
                            <p class="car-introinfo">
                                <span>自动</span>
                                <span>|</span>
                                <span>${car.carEngineCapcity}</span>
                                <span>T</span>
                                <a href="${pageContext.request.contextPath}/car/${car.carId}?menberId=${customer.memberId}"
                                   class="show-car-detail">
                                    车辆详情</a>
                            </p>
                        </div>
                        <div class="licar-info">
                            <p class="condition1">
                                                    <span class="carprice">
                                                        <i class="symbol">￥</i>
                                                        <em class="total-price">${car.carDailyPrice}</em>/日均
                                                    </span>
                                <span class="licar-btn">
                                    <c:if test="${!empty customer}">
                                        <a class="create_order" href="javascript:void(0)">预订</a>
                                    </c:if>
                                    <c:if test="${empty customer}">
                                        <a href="${pageContext.request.contextPath}/customer/login.jsp">预订</a>
                                    </c:if>

                                                    </span>
                            </p>
                        </div>
                    </li>
                </c:forEach>
            </c:if>


        </ul>

    </div>
    <!--多条件选择区域结束-->
    <div class="car-page" id="demo1">
        <%--        ${pageInfo}--%>

        <c:if test="${!empty pageInfo}">
            <c:if test="${pageInfo.pageNum > 1}">
                <a href="${pageContext.request.contextPath}/car/${keyword}/page/${pageInfo.pageNum - 1}">上一页</a>
            </c:if>
            <span style="margin: 0 auto">当前第 ${pageInfo.pageNum} 页</span>
            <c:if test="${pageInfo.pageNum < pageInfo.pages}">
                <a href="${pageContext.request.contextPath}/car/${keyword}/page/${pageInfo.pageNum + 1}">下一页</a>
            </c:if>
        </c:if>
        <c:if test="${!empty pageInfoAll}">
            <c:if test="${pageInfoAll.pageNum > 1}">
                <a href="${pageContext.request.contextPath}/car/getAll/page/${pageInfoAll.pageNum - 1}">上一页</a>
            </c:if>
            <span style="margin: 0 auto">当前第 ${pageInfoAll.pageNum} 页</span>
            <c:if test="${pageInfoAll.pageNum < pageInfoAll.pages}">
                <a href="${pageContext.request.contextPath}/car/getAll/page/${pageInfoAll.pageNum + 1}">下一页</a>
            </c:if>
        </c:if>

    </div>

    <!--============================汽车详情框=============================-->
    <div class="show-car-hide"></div>

    <%--        <script src="${pageContext.request.contextPath}/js/car-search.js"></script>--%>


    <script>
        $("#test-limit-one").blur(function () {
        });
        $("#test-limit-two").blur(function () {
            // console.log("hello");
        })

        /*====================ajax car数据渲染================*/
        // 初始化多条件查询
        /*showCarList("全部", "全部",
            "全部",
            "全部", "全部",
            "默认排序",1);*/

        var globalCarType;
        var globalCarBrand;
        var globalCarDailyPrice;
        var globalCarShiftType;
        var globalCarSeatNumber;
        var globalOrderBy;
        var globalPageNum;

        // 分页根据多条件进行分页查询
        function showCarList(carType, carBrand,
                             carDailyPrice,
                             carShiftType, carSeatNumber,
                             orderBy, pageNum) {
            globalCarType = carType;
            globalCarBrand = carBrand;
            globalCarDailyPrice = carDailyPrice;
            globalCarShiftType = carShiftType;
            globalCarSeatNumber = carSeatNumber;
            globalOrderBy = orderBy;
            globalPageNum = pageNum;

            var minCarDailyPrice;
            var maxCarDailyPrice;
            if (carType == "全部")
                carType = '-1';
            if (carBrand == "全部")
                carBrand = '-1';
            if (carDailyPrice == "全部") {
                minCarDailyPrice = -1;
                maxCarDailyPrice = -1;
            } else if (carDailyPrice == "100元以下") {
                minCarDailyPrice = -1;
                maxCarDailyPrice = 100;
            } else if (carDailyPrice == "100-200元") {
                minCarDailyPrice = 100;
                maxCarDailyPrice = 200;
            } else if (carDailyPrice = "200-300元") {
                minCarDailyPrice = 200;
                maxCarDailyPrice = 300;
            } else if (carDailyPrice = "300元以上") {
                minCarDailyPrice = 300;
                maxCarDailyPrice = -1;
            }
            if (carShiftType == "全部")
                carShiftType = "-1";
            if (carSeatNumber == "全部")
                carSeatNumber = -1;
            else if (carSeatNumber == "2座")
                carSeatNumber = 2;
            else if (carSeatNumber == "4座")
                carSeatNumber = 4;
            else if (carSeatNumber == "5座")
                carSeatNumber = 5;
            else if (carSeatNumber == "7座")
                carSeatNumber = 7;
            if (orderBy == "默认排序")
                orderBy = "-1";
            else if (orderBy == "按租金降序")
                orderBy = "car_daily_price desc";
            else if (orderBy == "按租金升序")
                orderBy = "car_daily_price asc";
            if (orderBy == "按排量降序")
                orderBy = "car_displacement desc";
            else if (orderBy == "按排量升序")
                orderBy = "car_displacement asc";
            if (typeof (pageNum) != "number")
                pageNum = 1;
            var url = '${pageContext.request.contextPath}/car/' + carType + '/'
                + carBrand + '/' + minCarDailyPrice + '/' + maxCarDailyPrice + '/' + carShiftType + '/' + carSeatNumber + '/' + orderBy + '/' + pageNum + '';
            $.get(url, null,
                function (result) {
                    $(".det-carlist ul").html("");
                    // console.log(JSON.stringify(result));

                    if (result.code == 200) {
                        var carArray = result.data.list;
                        for (var i = 0; i < carArray.length; i++) {
                            var carId = carArray[i].carId;
                            var carName = carArray[i].carBrand + carArray[i].carName;
                            var carDailyPrice = carArray[i].carDailyPrice;
                            var carImagePath = carArray[i].carImage;
                            var carShiftType = carArray[i].carShiftType;
                            var carDisplacement = carArray[i].carSeatCount;
                            console.log("hello")
                            if (carDisplacement == 2 || carDisplacement == 3) {
                                carDisplacement += ".0";
                            }
                            var carAirInletMode = carArray[i].carAirInletMode;
                            var custId = "${loginCustomer.custId}";
                            if (carAirInletMode == "自然进气")
                                carAirInletMode = "L";
                            else
                                carAirInletMode = "T";
                            <%--var liEle = '<li class="licar-picbox">\n' +--%>
                            <%--    '                <div class="licar-picinfo">\n' +--%>
                            <%--    '                    <img src="' + carImagePath + '">\n' +--%>
                            <%--    '                </div>\n' +--%>
                            <%--    '                <div class="licar-namebox">\n' +--%>
                            <%--    '                    <p class="car-nameinfo"><span>' + carName + '</span></p>\n' +--%>
                            <%--    '                    <p class="car-introinfo">\n' +--%>
                            <%--    '                            <span>\n' +--%>
                            <%--    '                                ' + carShiftType + '\n' +--%>
                            <%--    '                            </span>\n' +--%>
                            <%--    '                        <span>|</span>\n' +--%>
                            <%--    '                        <span>' + carDisplacement + '</span>\n' +--%>
                            <%--    '                        <span>' + carAirInletMode + '</span>\n' +--%>
                            <%--    '                        <a href="${pageContext.request.contextPath}/car/detail/' + carId + '" class="show-car-detail">车辆详情</a>\n' +--%>
                            <%--    '                    </p>\n' +--%>
                            <%--    '                </div>\n' +--%>
                            <%--    '                <div class="licar-info">\n' +--%>
                            <%--    '                    <p class="condition1">\n' +--%>
                            <%--    '                            <span class="carprice">\n' +--%>
                            <%--    '                                <i class="symbol">￥</i>\n' +--%>
                            <%--    '                                <em class="total-price">' + carDailyPrice + '</em>/日均\n' +--%>
                            <%--    '                            </span>\n' +--%>
                            <%--    '                        <span class="licar-btn">\n  <i style="display: none">' + carId + '</i>' +--%>
                            <%--    '                                <a style="width: 83px;height: 30px;display:inline-block;" href="javascript:void(0)">预订</a>\n' +--%>
                            <%--    '                            </span>\n' +--%>
                            <%--    '                    </p>\n' +--%>
                            <%--    '                </div>\n' +--%>
                            <%--    '            </li>';--%>
                            <%--    --%>


                            var liElement = '';
                            $(".det-carlist ul").append(liEle);
                        }


                        // var pageNum = result.data.pageNum;
                        var pages = result.data.pages;
                        var prePage = result.data.prePage;
                        var nextPage = result.data.nextPage;
                        var hasPreviousPage = result.data.hasPreviousPage;
                        var hasNextPage = result.data.hasNextPage;
                        var total = result.data.total;
                        var pageEle = "";
                        $(".bottom-right span").text(total);
                        // '<li class="licar-picbox">\n' +
                        // '                            共有<span>56</span>条评价\n' +
                        // '                            第<span>1</span>页\n' +
                        // '                            <a href="">上一页</a>\n' +
                        // '                            <a href="">下一页</a>\n' +
                        // '                            共有<span>5</span>页\n' +
                        // '                        </li>'
                        //     var a = "第<span>1</span>页\n" +
                        //         "                            <a href=\"javascript:showCarList(globalCarType,globalCarBrand,\n" +
                        //         "\t\t\t\t\t\t\'"+tglobalCarDailyPrice+"','"+globalCarShiftType+"','"+globalCarSeatNumber+"' ,\n" +
                        //         "\t\t\t\t\t\t\'"+tglobalOrderBy+"',"+prePage+")\">上一页</a>\n" +
                        //         "                            <a href=\"\">下一页</a>\n" +
                        //         "                            共有<span>5</span>页"

                        pageEle += "                          共有<span>" + total + "</span>条数据\n";

                        pageEle += "                            当前第<span>" + pageNum + "</span>页\n";
                        if (hasPreviousPage) {
                            pageEle += "                            <a href=\"javascript:showCarList('" + globalCarType + "','" + globalCarBrand + "',\n" +
                                "\t\t\t\t\t\t\t'" + globalCarDailyPrice + "','" + globalCarShiftType + "','" + globalCarSeatNumber + "' ,\n" +
                                "\t\t\t\t\t\t\t'" + globalOrderBy + "'," + prePage + ")\">上一页</a>\n";
                        }

                        if (hasNextPage) {
                            pageEle += "                            <a href=\"javascript:showCarList('" + globalCarType + "','" + globalCarBrand + "',\n" +
                                "\t\t\t\t\t\t\t'" + globalCarDailyPrice + "','" + globalCarShiftType + "','" + globalCarSeatNumber + "' ,\n" +
                                "\t\t\t\t\t\t\t'" + globalOrderBy + "'," + nextPage + ")\">下一页</a>\n";
                        }
                        pageEle += '                            共有<span>' + pages + '</span>页\n';
                        $(".car-page").html("");
                        $(".car-page").append(pageEle);
                    } else {
                        var noCar = '<div id="nocar" style="display: block;">\n' +
                            '            <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/nocar.png" alt="">\n' +
                            '            <div class="nocar-explain">\n' +
                            '                <p class="nocar-text1">对不起，当前门店该时间段内车辆已经租满。</p>\n' +
                            '                <p class="nocar-text2">您可以重新选择其他门店。</p>\n' +
                            '            </div>\n' +
                            '        </div>';
                        $(".det-carlist ul").append(noCar);
                        $(".bottom-right span").text(0);
                    }
                });
        }

        // 初始化
        function showCarListByContainAndStore(storeId,
                                              getCarTime,
                                              carType,
                                              carBrand,
                                              carDailyPrice,
                                              carShiftType,
                                              carSeatNumber,
                                              orderBy,
                                              pageNum
        ) {
            globalCarType = carType;
            globalCarBrand = carBrand;
            globalCarDailyPrice = carDailyPrice;
            globalCarShiftType = carShiftType;
            globalCarSeatNumber = carSeatNumber;
            globalOrderBy = orderBy;
            globalPageNum = pageNum;
            var minCarDailyPrice;
            var maxCarDailyPrice;
            if (carType == "全部")
                carType = "-1";
            if (carBrand == "全部")
                carBrand = "-1"
            if (carDailyPrice == "全部") {
                minCarDailyPrice = -1;
                maxCarDailyPrice = -1;
            } else if (carDailyPrice == "100元以下") {
                minCarDailyPrice = -1;
                maxCarDailyPrice = 100;
            } else if (carDailyPrice == "100-200元") {
                minCarDailyPrice = 100;
                maxCarDailyPrice = 200;
            } else if (carDailyPrice = "200-300元") {
                minCarDailyPrice = 200;
                maxCarDailyPrice = 300;
            } else if (carDailyPrice = "300元以上") {
                minCarDailyPrice = 300;
                maxCarDailyPrice = -1;
            }
            if (carShiftType == "全部")
                carShiftType = "-1";
            if (carSeatNumber == "全部")
                carSeatNumber = -1
            else if (carSeatNumber == "2座")
                carSeatNumber = 2;
            else if (carSeatNumber == "4座")
                carSeatNumber = 4;
            else if (carSeatNumber == "5座")
                carSeatNumber = 5;
            else if (carSeatNumber == "7座")
                carSeatNumber = 7;

            if (orderBy == "默认排序")
                orderBy = "-1"
            else if (orderBy == "按租金降序")
                orderBy = "car_daily_price desc"
            else if (orderBy == "按租金升序")
                orderBy = "car_daily_price asc"
            else if (orderBy == "按排量降序")
                orderBy = "car_displacement desc"
            else if (orderBy == "按排量升序")
                orderBy = "car_displacement asc"
            if (typeof (pageNum) != "number")
                pageNum = 1;

            if (typeof (pageNum) != "number")
                pageNum = 1;
            var url = "${pageContext.request.contextPath}/car/ContainAndDate";
            $.get(url,
                {
                    storeId: storeId,
                    getCarTime: getCarTime,
                    carType: carType,
                    carBrand: carBrand,
                    minCarDailyPrice: minCarDailyPrice,
                    maxCarDailyPrice: maxCarDailyPrice,
                    carShiftType: carShiftType,
                    carSeatNumber: carSeatNumber,
                    orderBy: orderBy,
                    pageNum: pageNum
                },
                function (result) {
                    $(".det-carlist ul").html("");
                    $(".car-page").html("");
                    if (result.code == 200) {

                        if (result.code == 200) {
                            var carArray = result.data.list;
                            for (var i = 0; i < carArray.length; i++) {
                                var carId = carArray[i].carId;
                                var carName = carArray[i].carBrand + carArray[i].carName;
                                var carDailyPrice = carArray[i].carDailyPrice;
                                var carImagePath = carArray[i].carImage;
                                var carShiftType = carArray[i].carShiftType;
                                var carDisplacement = carArray[i].carEngineCapcity;
                                var carAirInletMode = carArray[i].carAirInletMode;

                                var getCarShop = $("#borrow-store").val();
                                console.log("取车门店：" + getCarShop);
                                var returnCarShop = $("#return-store").val();
                                console.log("returnCarShop：" + returnCarShop);
                                var startDate = $("#test-limit-one").val() + " " + $("#test-limit-three").val()
                                console.log("startDate：" + startDate);
                                var endDate = $("#test-limit-two").val() + " " + $("#test-limit-four").val();
                                console.log("endDate：" + endDate);
                                var cusId = '${customer.memberId}'
                                console.log("cusId：" + cusId)

                                var getCity = $(".getCite").val();
                                var returnCity = $(".returnCity").val();

                                var newurl = "${pageContext.request.contextPath}/order/" + cusId + "/" + carId + "/" + getCarShop +
                                    "/" + returnCarShop + "/" + startDate + "/" + endDate + "/" +
                                    carName + "/" + carDailyPrice + "/" + getCity + "/" + returnCity;

                                console.log(carId + ":" + carName + ":" + carDailyPrice + ":" + carImagePath)
                                if (carDisplacement == 1 || carDisplacement == 2 || carDisplacement == 3) {
                                    carDisplacement += ".0";
                                    console.log("heloejfowj")
                                }
                                var custId = "${loginCustomer.custId}";
                                if (carAirInletMode == "自然进气")
                                    carAirInletMode = "L";
                                else
                                    carAirInletMode = "T";
                                var liEle = '<li class="licar-picbox">\n' +
                                    '                <div class="licar-picinfo">\n' +
                                    '                    <img src="${pageContext.request.contextPath}' + carImagePath + '">\n' +
                                    '                    <input type="hidden" value=carId>' +
                                    '                </div>\n' +
                                    '                <div class="licar-namebox">\n' +
                                    '                    <p class="car-nameinfo"><span>' + carName + '</span></p>\n' +
                                    '                    <p class="car-introinfo">\n' +
                                    '                            <span>\n' +
                                    '                                ' + "自动" + '\n' +
                                    '                            </span>\n' +
                                    '                        <span>|</span>\n' +
                                    '                        <span>' + carDisplacement + '</span>\n' +
                                    '                        <span>' + carAirInletMode + '</span>\n' +
                                    '                        <a href="${pageContext.request.contextPath}/car/' + carId + '" class="show-car-detail">车辆详情</a>\n' +
                                    '                    </p>\n' +
                                    '                </div>\n' +
                                    '                <div class="licar-info">\n' +
                                    '                    <p class="condition1">\n' +
                                    '                            <span class="carprice">\n' +
                                    '                                <i class="symbol">￥</i>\n' +
                                    '                                <em class="total-price">' + carDailyPrice + '</em>/日均\n' +
                                    '                            </span>\n' +
                                    '                        <span class="licar-btn">\n  <i style="display: none">' + carId + '</i>' +
                                    '                           <c:if test="${!empty customer}"><a class="create_order" style="width: 83px;height: 30px;display:inline-block;" href="${pageContext.request.contextPath}/order?' + 'cusId=' + cusId + '&carId=' + carId + '&getCarShop=' + getCarShop + '&returnCarShop=' + returnCarShop + '&startDate=' + startDate + '&endDate=' + endDate + '&carName=' + carName + '&price=' + carDailyPrice + '&getCity=' + getCity + '&returnCity=' + returnCity + '">预订</a></c:if>\n' +
                                    '                           <c:if test="${empty customer}"><a href="${pageContext.request.contextPath}/customer/login.jsp">预订</a></c:if> ' +
                                    '                            </span>\n' +
                                    '                    </p>\n' +
                                    '                </div>\n' +
                                    '            </li>';
                                $(".det-carlist ul").append(liEle);
                            }
                        }

                        // var pageNum = result.data.pageNum;
                        var pages = result.data.pages;
                        var prePage = result.data.prePage;
                        var nextPage = result.data.nextPage;
                        var hasPreviousPage = result.data.hasPreviousPage;
                        var hasNextPage = result.data.hasNextPage;
                        var total = result.data.total;
                        var pageEle = "";
                        $(".bottom-right span").text(total);
                        // '<li class="licar-picbox">\n' +
                        // '                            共有<span>56</span>条评价\n' +
                        // '                            第<span>1</span>页\n' +
                        // '                            <a href="">上一页</a>\n' +
                        // '                            <a href="">下一页</a>\n' +
                        // '                            共有<span>5</span>页\n' +
                        // '                        </li>'
                        //     var a = "第<span>1</span>页\n" +
                        //         "                            <a href=\"javascript:showCarList(globalCarType,globalCarBrand,\n" +
                        //         "\t\t\t\t\t\t\'"+tglobalCarDailyPrice+"','"+globalCarShiftType+"','"+globalCarSeatNumber+"' ,\n" +
                        //         "\t\t\t\t\t\t\'"+tglobalOrderBy+"',"+prePage+")\">上一页</a>\n" +
                        //         "                            <a href=\"\">下一页</a>\n" +
                        //         "                            共有<span>5</span>页"

                        pageEle += "                          共有<span>" + total + "</span>条数据\n";

                        pageEle += "                            当前第<span>" + pageNum + "</span>页\n";
                        if (hasPreviousPage) {
                            pageEle += "                            <a href=\"javascript:showCarListByContainAndStore('" + storeId + "', '" + getCarTime + "','" + globalCarType + "','" + globalCarBrand + "',\n" +
                                "\t\t\t\t\t\t\t'" + globalCarDailyPrice + "','" + globalCarShiftType + "','" + globalCarSeatNumber + "' ,\n" +
                                "\t\t\t\t\t\t\t'" + globalOrderBy + "'," + prePage + ")\">上一页</a>\n";
                        }

                        if (hasNextPage) {
                            pageEle += "                            <a href=\"javascript:showCarListByContainAndStore('" + storeId + "', '" + getCarTime + "','" + globalCarType + "','" + globalCarBrand + "',\n" +
                                "\t\t\t\t\t\t\t'" + globalCarDailyPrice + "','" + globalCarShiftType + "','" + globalCarSeatNumber + "' ,\n" +
                                "\t\t\t\t\t\t\t'" + globalOrderBy + "'," + nextPage + ")\">下一页</a>\n";
                        }
                        pageEle += '                            共有<span>' + pages + '</span>页\n';

                        $(".car-page").append(pageEle);
                    } else {
                        var noCar = '<div id="nocar" style="display: block;">\n' +
                            '            <img src="http://r1nxp2i0y.hn-bkt.clouddn.com/images/nocar.png" alt="">\n' +
                            '            <div class="nocar-explain">\n' +
                            '                <p class="nocar-text1">对不起，当前门店该时间段内车辆已经租满。</p>\n' +
                            '                <p class="nocar-text2">您可以重新选择其他门店。</p>\n' +
                            '            </div>\n' +
                            '        </div>';
                        $(".det-carlist ul").append(noCar);
                        $(".bottom-right span").text(0);
                    }
                });
        }

        // 根据店铺和租借时间以及多条件查询
        //======================================================
        // 初始化显示全部门店
        $("#borrow-store").click(function () {
            $("#borrow-store").val("");
        })
        $("#return-store").click(function () {
            $("#return-store").val("");
        })
        var storeArr;

        // initializationStore();

        function initializationStore() {
            $("#borrow-store").val("");
            var borrowStoreList = $("#borrow-store-list").html();
            if (borrowStoreList == "") {
                var storeCity = $("#J-city-get").val();
                var url = "${pageContext.request.contextPath}/store/" + storeCity;
                $.get(url, null,
                    function (result) {
                        storeArr = result.data;
                        for (var i = 0; i < storeArr.length; i++) {
                            var optionEle = '<option>' + storeArr[i].storeName + '</option>\n';
                            $("#borrow-store-list").append(optionEle);
                            $("#return-store-list").append(optionEle);
                        }

                        $("#borrow-store").val(storeArr[0].storeName);
                        $("#return-store").val(storeArr[0].storeName);
                        $("#borrow-store-id").text(storeArr[0].storeId);
                        $("#return-store-id").text(storeArr[0].storeId);

                        var getCarDate = $("#test-limit-one").val();
                        var getCarTime = $("#test-limit-three").val();

                        getCarTime = getCarDate + " " + getCarTime;
                        getCarTime = new Date(getCarTime);

                        showCarListByContainAndStore(
                            storeArr[0].storeId,
                            getCarTime,
                            "全部",
                            "全部",
                            "全部",
                            "全部",
                            "全部",
                            "默认排序",
                            1
                        )


                    });
            }
        }

        $("#borrow-store").blur(function () {
            setSpanBorrowStoreId(storeArr);
        });
        $("#return-store").blur(function () {
            setSpanReturnStoreId(storeArr)
        });

        function setSpanBorrowStoreId(storeArr) {
            var borrowStoreName = $("#borrow-store").val();

            if (borrowStoreName != "") {
                for (var j = 0; j < storeArr.length; j++) {
                    var storeName = storeArr[j].storeName;
                    var storeId = storeArr[j].storeId;
                    if (borrowStoreName == storeName) {
                        $("#borrow-store-id").text(storeId);
                        var getStoreUrl = "${pageContext.request.contextPath}/get_store/by_id";
                        $.get(getStoreUrl, {
                            storeId: storeId
                        }, function (result) {
                            $("#right-store").html("");
                            console.log(JSON.stringify(result));
                            var storeName = result.data.storeName;
                            var storeTel = result.data.storeTel;
                            var storeBusinessTime = result.data.storeBusinessTime;
                            var storeProvince = result.data.storeProvince;
                            var storeCity = result.data.storeCity;
                            var storeArea = result.data.storeArea;
                            var storeDetailAddress = result.data.storeDetailAddress;
                            storeDetailAddress = storeProvince + "省" + storeCity + "市" + storeArea + storeDetailAddress;
                            var liEle = '   <li>取车门店：</li>\n' +
                                '            <li>\n' +
                                '                <h4>' + storeName + '</h4>\n' +
                                '            </li>\n' +
                                '            <li>\n' +
                                '                <span>' + storeDetailAddress + '</span>\n' +
                                '            </li>\n' +
                                '            <li>\n' +
                                '                <strong>门店电话：<span>' + storeTel + '</span></strong>\n' +
                                '            </li>\n' +
                                '            <li>\n' +
                                '                <strong>营业时间：<span>' + storeBusinessTime + '</span></strong>\n' +
                                '            </li>';
                            $("#right-store").append(liEle);
                        })
                        break;
                    } else if (j == storeArr.length - 1) {
                        alert("门店名输入有误~重新选择下吧~")
                        $("#borrow-store").val(storeArr[0].storeName)
                    }
                    // else if()
                }
            } else {
                alert("请选择门店~");
                $("#borrow-store").val(storeArr[0].storeName)
            }
        }

        // function setSpanReturnStoreId(storeArr) {
        //     // console.log("hello");
        //     var returnStoreName = $("#return-store").val();
        //     // console.log("returnStoreName != 空："+ (returnStoreName != ""));
        //     // console.log("returnStoreName" + returnStoreName);
        //
        //     if (returnStoreName != "") {
        //         for (var j = 0; j < storeArr.length; j++) {
        //             var storeName = storeArr[j].storeName;
        //             var storeId = storeArr[j].storeId;
        //             if (returnStoreName == storeName) {
        //                 $("#return-store-id").text(storeId);
        //                 break;
        //             } else if (j == storeArr.length - 1) {
        //                 alert("门店名输入有误~重新选择下吧~")
        //                 $("#return-store").val(storeArr[0].storeName)
        //             }
        //             // else if()
        //         }
        //     } else {
        //         alert("请选择门店~");
        //         $("#return-store").val(storeArr[0].storeName)
        //     }
        // }

        <%--$(".det-carlist").click(function (event) {--%>
        <%--    var eventText = event.target.innerText;--%>
        <%--    var custId = "${loginCustomer.custId}";--%>
        <%--    if (eventText == "预订") {--%>
        <%--        if (custId != "") {--%>
        <%--            var carId = event.target.parentElement.children[0].innerText;--%>
        <%--            var borrowStoreId = $("#borrow-store-id").text();--%>
        <%--            var returnStoreId = $("#return-store-id").text();--%>

        <%--            var getCarDate = $("#test-limit-one").val();--%>
        <%--            var getCarTime = $("#test-limit-three").val();--%>
        <%--            var returnCarDate = $("#test-limit-two").val();--%>
        <%--            var returnCarTime = $("#test-limit-four").val();--%>
        <%--            // console.log("borrowStoreName: " + borrowStoreId);--%>
        <%--            // console.log("returnStore: " + returnStoreId);--%>
        <%--            // console.log("carId: " + carId);--%>
        <%--            // console.log("custId: " + custId);--%>
        <%--            getCarTime = getCarDate + " " + getCarTime;--%>
        <%--            // console.log("getCarTime:"+getCarTime);--%>

        <%--            returnCarTime = returnCarDate + " " + returnCarTime;--%>
        <%--            var returnCarTime2 = new Date(returnCarTime);--%>

        <%--            returnCarTime2 = returnCarTime2.setHours(returnCarTime2.getHours() - 9);--%>

        <%--            // console.log("returnCarTime: " + returnCarTime);--%>
        <%--            // console.log("getCarTime:" + new Date(getCarTime));--%>
        <%--            if (new Date(getCarTime) <= new Date()) {--%>
        <%--                alert("取车时间不能小于当前时间~");--%>
        <%--            } else if (new Date(getCarTime) >= returnCarTime2) {--%>
        <%--                alert("取车时间与还车时间间隔不能小于九个小时~");--%>
        <%--            } else {--%>
        <%--                var storeCarUrl = "${pageContext.request.contextPath}/get/store_and_car";--%>
        <%--                $.get(storeCarUrl, {--%>
        <%--                        storeId: borrowStoreId,--%>
        <%--                        carId: carId--%>
        <%--                    },--%>
        <%--                    function (result) {--%>
        <%--                        console.log(JSON.stringify(result));--%>
        <%--                        if (result.data.carReserve > 0) {--%>
        <%--                            var url = '${pageContext.request.contextPath}/myOrder_second?custId=' + custId + '&carId=' + carId + '&borrowStoreId=' + borrowStoreId + '&returnStoreId=' + returnStoreId + '&getCarTime=' + getCarTime + '&returnCarTime=' + returnCarTime + '';--%>
        <%--                            window.location.href = url;--%>
        <%--                        } else {--%>
        <%--                            console.log("点击订单详情可以查看租借表哦！")--%>
        <%--                            alert("抱歉亲，这辆车有人比你先一步租借走啦！")--%>

        <%--                        }--%>
        <%--                    }, "json")--%>

        <%--            }--%>

        <%--        } else {--%>
        <%--            window.location.href = "${pageContext.request.contextPath}/customer/login";--%>
        <%--        }--%>
        <%--    }--%>
        <%--});--%>
        window.onscroll = function () {
            if (window.pageYOffset >= 150) {
                document.querySelector(".step1-body-right").classList.add("step1-right-float");
            } else {
                document.querySelector(".step1-body-right").classList.remove("step1-right-float");
            }
        }
    </script>

    <script src="${pageContext.request.contextPath}/layui/layui.js"></script>
    <script src="${pageContext.request.contextPath}/js/select_car.js"></script>

    <script>
        var map = new BMapGL.Map("container");          // 创建地图实例
        var point = new BMapGL.Point(120.56873, 31.31052);
        map.centerAndZoom(point, 15);                 // 初始化地图，设置中心点坐标和地图级别
        map.enableDragging();//启用地图拖拽事件，默认启用(可不写)
        map.enableKeyboard();//启用键盘上下左右键移动地图
    </script>

    <script>
        $(".create_order").click(function (event) {
            console.log("开始执行预定")

            var ele = event.target;
            // console.log(ele)
            var liEle = ele.parentElement.parentElement.parentElement.parentElement

            var getCarShop = $("#borrow-store").val();
            console.log("取车门店：" + getCarShop);
            var returnCarShop = $("#return-store").val();
            console.log("returnCarShop：" + returnCarShop);
            var startDate = $("#test-limit-one").val() + " " + $("#test-limit-three").val()
            console.log("startDate：" + startDate);
            var endDate = $("#test-limit-two").val() + " " + $("#test-limit-four").val();
            console.log("endDate：" + endDate);
            // console.log(liEle)
            var carName = liEle.firstElementChild.nextElementSibling.firstElementChild.firstElementChild.innerText
            console.log("carName：" + carName);
            var price = liEle.lastElementChild.firstElementChild.firstElementChild.lastElementChild.innerText
            console.log("price：" + price);
            var cusId = '${customer.memberId}'
            console.log("cusId：" + cusId)
            var carId = liEle.firstElementChild.lastElementChild.value
            console.log("carId:" + carId)
            var getCity = $(".getCite").val();
            var returnCity = $(".returnCity").val();

            var newurl = '${pageContext.request.contextPath}/order?' + 'cusId=' + cusId + '&carId=' + carId + '&getCarShop=' + getCarShop +
                '&returnCarShop=' + returnCarShop + '&startDate=' + startDate + '&endDate=' + endDate + '&carName=' + carName + '&price=' + price +
                '&getCity=' + getCity + '&returnCity=' + returnCity;

            console.log(newurl)
            window.location.href = newurl;

            //     $.ajax({
            //     url: newurl,
            //     type: 'get',
            //     async: false,
            //     data: {
            //         "getCarShop": getCarShop, "returnCarShop": returnCarShop,
            //         "startDate": startDate, "endDate": endDate, "carName": carName,
            //         "price": price, "cusId": cusId, "carId": carId, "getCity": getCity,
            //         "returnCity": returnCity
            //     },
            //     success: function (result) {
            //         console.log(result)
            //         window.location.href = this.url;
            //     }, error: function () {
            //         alert("该门店不存在")
            //     }
            // })
        })
    </script>

</body>


</html>
